package com.abc.config;

import com.abc.config.memory.MongodbChatMemory;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.PromptChatMemoryAdvisor;
import org.springframework.ai.zhipuai.ZhiPuAiChatModel;
import org.springframework.ai.zhipuai.ZhiPuAiChatOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ModelConfig {

    @Autowired
    private DashScopeChatModel dashScopeChatModel;

    @Autowired
    private ZhiPuAiChatModel zhiPuAiChatModel;

    @Autowired
    private MongodbChatMemory chatMemory;

    @Bean
    public ChatClient dashScopeChatClient() {
        return ChatClient.builder(dashScopeChatModel)
                .defaultAdvisors(PromptChatMemoryAdvisor.builder(chatMemory).build())
                .defaultOptions(DashScopeChatOptions.builder().withModel("qwen-plus-2025-07-14").build())
                .build();
    }

    @Bean
    public ChatClient zhipuChatClient() {
        return ChatClient.builder(zhiPuAiChatModel)
                .defaultAdvisors(PromptChatMemoryAdvisor.builder(chatMemory).build())
                .defaultOptions(ZhiPuAiChatOptions.builder().model("GLM-4.5-FLASH").build()).build();
    }

}
